<template>
	<view class="wrapper">
		<dlContacts ref="jContacts"  :myList="myList" @confirm='confirm'></dlContacts>
	</view>
</template>

<script>
	import dlContacts from '@/components/dl-contacts/dl-contacts.vue';
	export default {
		data() {
			return {
				myList:[]
			};
		},
		onLoad(e) {
			e.list=e.list || '[]'
			this.getFriendList(JSON.parse(e.list));
		},
		methods: {
			confirm(list){
				getApp().globalData.contactList=list
				this.$back()
			},
			getFriendList(list) {
				const that=this
				this.$ajax(this.apiList.friendsList, { 
					userId: uni.getStorageSync('userinfo').userId
				}).then(res => {
					// 过滤掉客服
					res.data=res.data.filter(item => {
						return item.toNickname!='客服公众号'
					})
					let is
					res.data=res.data.filter(item => {
						is=true
						list.map(val => {
							console.log(item.toUserId==val)
							if(item.toUserId==val){
								is=false
							}
						})
						return is
					})
					this.myList=res.data
					setTimeout(function(){
						that.$refs.jContacts.show();
					},300)
				});
			}
		},
		components: { dlContacts }
	}
</script>

<style lang="scss">

</style>
